import json
import os
import logging

# 创建日志记录器
def create_logger():
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s | 文件:%(filename)s,函数:%(funcName)s')
    return logging


# 加载语言数据
def load_language_data():
    """加载语言数据"""
    try:
        with open('language.json', 'r', encoding='utf-8') as f:  # 明确指定utf-8编码
            language_data = json.load(f)
        logging.info("成功加载语言数据")
        return language_data
    except Exception as e:
        logging.error(f"Failed to load language data: {e}")
        return None

# 写入语言数据
def write_language_data(language_data, key, value):
    language_data[key] = value
    with open('language.json', 'w', encoding='utf-8') as f:
        json.dump(language_data, f, ensure_ascii=False, indent=4)


#################### 以下是载入代码 ####################
language_data = load_language_data()
logging = create_logger()



